using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using FoundationLib.Ifc.Domain;


namespace FoundationLib.Ifc.Data 
{
	/// <summary>
	/// Provides an interface for aggregate-specific event storage
	/// </summary>
	public interface IAggregateEventStorage
	{
		/// <summary>
		/// Gets all events associated with the given aggregate key
		/// </summary>
		/// <param name="aggregateKey">The aggregate key</param>
		IEnumerable<IVersionedEvent> GetAll(object aggregateKey);

		/// <summary>
		/// Saves only the specified events for the given event-sourced aggregate
		/// </summary>
		/// <param name="aggregateKey">The aggregate key</param>
		/// <param name="events">The events to store</param>
		void Save(object aggregateKey, IEnumerable<IVersionedEvent> events);

		/// <summary>
		/// Saves all pending events for the given event-sourced aggregate
		/// </summary>
		/// <param name="aggregateKey">The aggregate key</param>
		/// <param name="events">The events to store</param>
		/// <param name="expectedVersion">The expected version used for concurrency
		/// conflict detection</param>
		void Save(object aggregateKey, IEnumerable<IVersionedEvent> events, int expectedVersion);
	}

}